import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID: majowi1
LANG: JAVA
PROG: namenum
*/

public final class namenum {
	public static void main(String[] args) throws IOException {
		BufferedReader dict = new BufferedReader(new FileReader("dict.txt"));	    
		BufferedReader f = new BufferedReader(new FileReader("namenum.in"));	    
	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("namenum.out")));
	    char[][] entrys = new char[][]{{'z','z','z'},{'z','z','z'},{'A','B','C'},{'D','E','F'},{'G','H','I'},{'J','K','L'},{'M','N','O'},{'P','R','S'},{'T','U','V'},{'W','X','Y'}};
	    String cowid = f.readLine().trim();
	    char[] entry ;
	    char[] name;
	    String curr_name;
	    int count = 0, lcount;
	    while ((curr_name = dict.readLine()) != null){
	    	if (curr_name.length() != cowid.length())
	    		continue;
	    	name = curr_name.toCharArray();	    	
	    	lcount = 0;
	    	for (int x = 0; x<cowid.length();x++){
	    		entry = entrys[Integer.parseInt(cowid.substring(x, x+1))];
	    		for (int y = 0; y < 3; y++)
	    			if(name[x] == entry[y])
	    				lcount++;
	    	}
	    	if (lcount == cowid.length()){
	    		out.println(new String(name));
	    		count++;
	    	}
    	}
	    if (count == 0)
	    	out.println("NONE");	    
	    out.close();
	    System.exit(0);	
	}
}
